<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text"> <button onclick="pd()">是否为两位数</button>
</body>

</html>
<script>
    var tex = document.querySelector('input')

    function pd() {
        alert('这是' + tex.value.length + '位数');
    }
</script>